package juc

import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import java.util.concurrent.CopyOnWriteArrayList

fun main() = runBlocking {
//    val list = mutableListOf<String>()
    val list = CopyOnWriteArrayList<String>()
    repeat(1000) {
        GlobalScope.launch { list.add(Thread.currentThread().name) }
    }
    delay(2000)
    println(list.size)
}